package com.example.mqtt.repository

import com.example.mqtt.domain.RecordData
import org.springframework.data.cassandra.repository.Query
import org.springframework.data.repository.CrudRepository


interface RecordDataRepository : CrudRepository<RecordData, String> {

    override fun findAll(): Iterable<RecordData>

    override fun <S : RecordData> save(entity: S): S

    fun findByMcuId(mcuId: String): List<RecordData>

    fun findByMcuIdAndYhubStime(mcuId: String, yhubStime: Long?): List<RecordData>

    fun findByMcuIdAndYhubStimeAndCycleId(mcuId: String, yhubStime: Long?, cycleId: Long?): List<RecordData>

    fun findByMcuIdAndYhubStimeGreaterThanAndYhubStimeLessThan(mcuId: String, yhubStime: Long?, yhubStime2: Long?): List<RecordData>

    fun deleteByMcuId(): Int

    @Query("select * from record_data where mcu_id = ?0 limit 1 ALLOW FILTERING")
    fun findByMcuIdLastRow(mcuId: String): List<RecordData>
}